package com.kj.tms.system.service.org.serviceImpl;


import com.kj.tms.common.bean.dao.BaseMapper;
import com.kj.tms.common.bean.dto.TreeData;
import com.kj.tms.common.bean.service.BaseService;
import com.kj.tms.common.utils.StringUtil;
import com.kj.tms.pri.system.org.dto.IndustryInfoDto;
import com.kj.tms.pri.system.org.service.IndustryInfoService;
import com.kj.tms.system.service.org.dao.IndustryInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;


/**
 * @ProjectName:
 * @Package: com.hongtu.tms.system.org.service.impl
 * @ClassName: IndustryInfoImpl
 * @Description: 行业信息IndustryInfoImpl
 * @Author: 董世栋
 * @CreateDate:
 * @UpdateUser:
 * @UpdateDate:
 * @UpdateRemark:
 * @Version: 1.0
 * Copyright: 北京宏图天安 Copyright (c) 2017
 */
@Service
public class IndustryInfoServiceImpl extends BaseService<IndustryInfoDto> implements IndustryInfoService {

    @Autowired
    private IndustryInfoMapper industryInfoMapper;

    @Override
    public BaseMapper<IndustryInfoDto> getMapper() {
        return industryInfoMapper;
    }

    private String industryInfoRoot = "000000";

    /**
     * @param id
     * @return list
     * @throws
     * @method listByPindustryCode
     * @description 通过上级代码获取行业信息
     * @author 董世栋
     * @version 1.0
     * @date
     */
    @Override
    public List<TreeData> listByPindustryCode(@RequestParam("id") String id) {
        List<TreeData> list = new ArrayList<TreeData>();
        if (StringUtil.isNull(id) || id.equals(industryInfoRoot)) {
            list = industryInfoMapper.listByPindustryCode(industryInfoRoot);
        } else {
            list = industryInfoMapper.listByPindustryCode(id);
        }
        return list;
    }

    /**
     * @param industryCode
     * @return IndustryInfoDto
     * @throws
     * @method getByCode
     * @description 通过子节点代码获取行业信息
     * @author 董世栋
     * @version 1.0
     * @date
     */
    @Override
    public IndustryInfoDto getByCode(@RequestParam("industryCode")String industryCode) {
        return industryInfoMapper.getByCode(industryCode);
    }

    /**
     * @param industryCode
     * @return industryName
     * @throws
     * @method getIndustryName
     * @description 获取行业信息name
     * @author 董世栋
     * @version 1.0
     * @date
     */
    @Override
    public String getIndustryName(@RequestParam("industryCode")String industryCode) {
        return industryInfoMapper.getIndustryName(industryCode);
    }

}

